package stack;

import java.util.Stack;

public class Bracket {
    public static void main(String[] args){
        String s="()";

        Stack<Character> m = new Stack<>();
        for(char c: s.toCharArray() ){
            if (c=='('||c=='{'||c=='[')
                m.push(c);
            else if (m.isEmpty())
                System.out.println("false");
            else if (c ==')'&& m.pop()!='(')
                System.out.println("false");
            else if (c =='}'&& m.pop()!='{')
                System.out.println("false");
            else if (c ==']'&& m.pop()!='[')
                System.out.println("false");
        }
        if(!m.isEmpty())
            System.out.println("false");
        System.out.println("true");
    }

}
